package com.three.controller;

import com.three.aop.LogAnotation;
import com.three.entity.Branch;
import com.three.entity.Goods;
import com.three.service.GoodsService;
import com.three.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @PostMapping("/list")
    public R list(Integer pageNum, Integer pageSize, @RequestBody KeyboardVO keyboardVO)
    {
        return goodsService.list(pageNum,pageSize,keyboardVO);
    }
    //新增
    @PostMapping("/addGoods")
    @LogAnotation(value = "进行商品的添加")
    public R add(@RequestBody Goods goods)
    {
        return goodsService.add(goods);
    }

    //编辑
    @PostMapping("/updateGoods")
    @LogAnotation(value = "进行商品的编辑")
    public R edit(@RequestBody Goods goods)
    {
        return goodsService.edit(goods);
    }
    //删除
    @DeleteMapping("/deleteGoods")
    @LogAnotation(value = "进行商品的删除")
    public R delete(Integer goodsid)
    {
        return goodsService.delete(goodsid);
    }


    //查找所有商品
    @PostMapping("/listgoods")
    public R getAllGoods(Integer currentPage, Integer pageSize, @RequestBody KeyboardVO keyboardVO)
    {
        return goodsService.getAllGoods(currentPage, pageSize, keyboardVO);
    }

    //在添加出库页面查询出所有商品信息
    @PostMapping("/getAllOutGoods")
    public R getAllGoods(Integer currentPage, Integer pageSize, @RequestBody AddOutLibrartVo addOutLibrartVo)
    {
        return goodsService.getAllOutGoods(currentPage,pageSize,addOutLibrartVo);
    }

    @GetMapping("/selectGoodsAll")
    public R getAllOutGoods(Integer pageNum, Integer pageSize,Integer branchid)
    {
        return goodsService.selectGoodsAll(pageNum,pageSize,branchid);
    }

//点击新增商品按钮展示所有
    @GetMapping("/listgoodsAll")
    public R selectList( Integer pageNum, Integer pageSize)
    {
        return goodsService.listgoods(pageNum,pageSize);
    }

    //添加商品
    @PostMapping("/addGoodsAll")
    @LogAnotation(value = "进行批量添加商品")
    public R addGoodsAll(@RequestBody List<AddintLibraryVO> addintLibraryVOList)
    {
        return goodsService.addGoodsAll(addintLibraryVOList);

    }
//根据登陆者的id显示商品
    @GetMapping("/getUserStaffId")
    public R selectByBranchid()
    {
        return goodsService.getUserStaffId();
    }


}
